package com.kamistoat.meimeistore.ware;

import com.kamistoat.meimeistore.ware.learn.LearnApplicationContextInitializer;
import com.kamistoat.meimeistore.ware.learn.LearnApplicationListener;
import com.kamistoat.meimeistore.ware.learn.LearnEventListener;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableRabbit
@EnableFeignClients(basePackages = "com.kamistoat.meimeistore.ware.feign")
@EnableTransactionManagement
@EnableDiscoveryClient
@MapperScan("com.kamistoat.meimeistore.ware.dao")
@SpringBootApplication
public class MeimeistoreWebBackstageWareApplication {
    /**
     * 默认的入口类写法
     * @param args
     */
//    public static void main(String[] args) {
//        SpringApplication.run(meimeistoreWareApplication.class, args);
//    }

    /**
     * 学习Springboot源码时进行的修改，为了使用上自定义的 ApplicationContextInitializer接口
     * 只是增加了一个打印Bean数量的Initializer，对业务逻辑毫无影响
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(MeimeistoreWebBackstageWareApplication.class);
        application.addInitializers(new LearnApplicationContextInitializer());
        application.addListeners(new LearnApplicationListener());
        application.addListeners(new LearnEventListener());
        application.run(args);
    }
}
